package com.henglian.verify.database

import android.content.Context
import androidx.room.Room

object AppDatabaseSingleton {
    private lateinit var db: AppDatabase

     fun init(context: Context) {
        db = Room.databaseBuilder(
            context.applicationContext,
            AppDatabase::class.java, "app-database"
        ).fallbackToDestructiveMigration().build()
    }

    fun getDatabase(): AppDatabase {
        if (!::db.isInitialized) {
            throw IllegalStateException("AppDatabase has not been initialized")
        }
        return db
    }
}
